from selenium import webdriver
from selenium.webdriver.common.by import By
import time


class Testcase:
    def __init__(self):
        # 初始化对象属性
        self.driver = webdriver.Chrome()

    def get_baidu(self):

        #请求百度
        self.driver.get('https://www.baidu.com')

        #搜索框输入内容
        time.sleep(2)
        self.driver.find_element(By.ID,'kw').send_keys('天气预报')

        # 点击百度一下
        time.sleep(2)
        self.driver.find_element(By.ID,'su').click()

    def get_so(self):
        # 请求360浏览器
        self.driver.get('https://www.so.com')

        # 搜索框输入内容
        time.sleep(3)
        self.driver.find_element(By.ID,'input').send_keys('爱奇艺')
        #点击搜索
        time.sleep(2)
        self.driver.find_element(By.ID,'search-button').click()

    # seconds 秒
    def quit(self, seconds=2):

        # 退出浏览器
        time.sleep(seconds)
        self.driver.quit()


if __name__ == '__main__':
    case = Testcase()
    case.get_baidu()
    case.quit()





